package com.crk.yiyuanguahao.controller;

import com.crk.yiyuanguahao.entity.DoctorComment;
import com.crk.yiyuanguahao.entity.DoctorCommentDto;
import com.crk.yiyuanguahao.service.DoctorCommentService;
import com.crk.yiyuanguahao.util.LayUiTableJson;
import com.crk.yiyuanguahao.util.Page;
import com.crk.yiyuanguahao.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author
 * @description:
 * @date 2020/3/26
 */
@RestController
@RequestMapping("doctorComment")
public class DoctorCommentController {
    @Autowired
    DoctorCommentService doctorCommentService;

    @RequestMapping("manage")
    public ModelAndView manage(){
        ModelAndView modelAndView = new ModelAndView("/workspace/doctorComment/doctorCommentList.html");
        return modelAndView;
    }

    @GetMapping("detail")
    public ModelAndView detail(){
        ModelAndView modelAndView = new ModelAndView("/workspace/doctorComment/doctorCommentAdd.html");
        return modelAndView;
    }

    @GetMapping("myDoctorComment")
    public ModelAndView myDoctorComment(){
        ModelAndView modelAndView = new ModelAndView("/workspace/doctorComment/myDoctorComment.html");
        return modelAndView;
    }

    @GetMapping("selfDoctorComment")
    public ModelAndView selfDoctorComment(){
        ModelAndView modelAndView = new ModelAndView("/workspace/doctorComment/doctorCommentSelf.html");
        return modelAndView;
    }

    @GetMapping("editDoctorComment")
    public ModelAndView editDoctorComment(){
        ModelAndView modelAndView = new ModelAndView("/workspace/doctorComment/doctorCommentEdit.html");
        return modelAndView;
    }

    @RequestMapping("saveDoctorComment")
    public ResponseResult saveDoctorComment(DoctorCommentDto doctorComment){
        return doctorCommentService.saveDoctorComment(doctorComment);
    }

    @RequestMapping("deleteDoctorComment")
    public ResponseResult deleteDoctorComment(@RequestParam("id") Integer id){
        return doctorCommentService.deleteDoctorComment(id);
    }

    @RequestMapping("getDoctorComment")
    public ResponseResult getDoctorComment(@RequestParam("id") Integer id){
        return doctorCommentService.getDoctorComment(id);
    }

    @RequestMapping("queryDoctorCommentPage")
    public LayUiTableJson queryDoctorCommentPage(String doctorCode
            , @RequestParam(defaultValue = "1") int page
            , @RequestParam(defaultValue = "10") int limit){
        Page pageInfo = new Page();
        pageInfo.setCurrentPage(page);
        pageInfo.setSize(limit);
        ResponseResult ResponseResult = doctorCommentService.queryDoctorCommentPage(doctorCode,pageInfo);
        LayUiTableJson layUiTableJson = new LayUiTableJson(0,null,pageInfo.getAllRow(),(List)ResponseResult.getData());
        return layUiTableJson;
    }

    @RequestMapping("queryMyDoctorCommentPage")
    public LayUiTableJson queryMyDoctorCommentPage(String doctorCode
            , @RequestParam(defaultValue = "1") int page
            , @RequestParam(defaultValue = "10") int limit){
        Page pageInfo = new Page();
        pageInfo.setCurrentPage(page);
        pageInfo.setSize(limit);
        ResponseResult ResponseResult = doctorCommentService.queryMyDoctorCommentPage(doctorCode,pageInfo);
        LayUiTableJson layUiTableJson = new LayUiTableJson(0,null,pageInfo.getAllRow(),(List)ResponseResult.getData());
        return layUiTableJson;
    }

    @RequestMapping("querySelfDoctorCommentPage")
    public LayUiTableJson querySelfDoctorCommentPage(String doctorCode
            , @RequestParam(defaultValue = "1") int page
            , @RequestParam(defaultValue = "10") int limit){
        Page pageInfo = new Page();
        pageInfo.setCurrentPage(page);
        pageInfo.setSize(limit);
        ResponseResult ResponseResult = doctorCommentService.querySelfDoctorCommentPage(pageInfo);
        LayUiTableJson layUiTableJson = new LayUiTableJson(0,null,pageInfo.getAllRow(),(List)ResponseResult.getData());
        return layUiTableJson;
    }

    @RequestMapping("getDoctorCommentByAppointment")
    public ResponseResult getDoctorCommentByAppointment(@RequestParam("appointmentId") Integer appointmentId){
        return doctorCommentService.getDoctorCommentByAppointment(appointmentId);
    }
}
